/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.his.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author his
* @date 2022-11-11
**/
@Entity
@Data
@Table(name="his_pharmacy")
public class Pharmacy extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`pharmacy_id`")
    @ApiModelProperty(value = "id")
    private Integer pharmacyId;

    @Column(name = "`pharmacy_name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "药品名称")
    private String pharmacyName;

    @Column(name = "`drugstore_id`")
    @ApiModelProperty(value = "领货单位")
    private Integer drugstoreId;

    @Column(name = "`skull_id`")
    @ApiModelProperty(value = "经办人")
    private Integer skullId;

    @Column(name = "`warehouse_id`")
    @ApiModelProperty(value = "库房")
    private Integer warehouseId;

    @Column(name = "`unit`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "计量单位")
    private Integer unit;

    @Column(name = "`selling_price`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "售价")
    private Double sellingPrice;

    @Column(name = "`area`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "产地")
    private Integer area;

    @Column(name = "`type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "类型")
    private Integer type;

    @Column(name = "`produce_date`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "生产日期")
    private Timestamp produceDate;

    @Column(name = "`valid_date`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "有效期")
    private Timestamp validDate;

    @Column(name = "`drugstore_num`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "数量")
    private Integer drugstoreNum;

    @Column(name = "`skull_batch`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "批号")
    private String skullBatch;

    public void copy(Pharmacy source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
